import time

import allure
from page_object.page_roncoo_pay_login import PageLogin
from page_element.el_Roncoo import *
import logging



class EditLogin(PageLogin):
    """首页搜索商品后退出登录"""

    def page_add_user(self, name, phone, password):
        # 前置条件：已登录
        self.page_login('admin', '123456')
        with allure.step("点击用户管理"):
            self.click(home_pe.user_manage)
        with allure.step("点击用户信息"):
            self.click(home_pe.user_info)
        with allure.step("点击添加用户按钮"):
            self.click(home_pe.add_user_btn)
        with allure.step("输入用户名称"):
            self.send_keys(home_pe.username_inp, name)
        with allure.step("输入手机号"):
            self.send_keys(home_pe.userphone_inp, phone)
        with allure.step("输入登录密码"):
            self.send_keys(home_pe.userpassword_inp, password)
        with allure.step("点击提交"):
            self.click(home_pe.tj_btn)
        time.sleep(5)
        with allure.step("验证搜索出来的用户名"):
            dy = self.text(home_pe.tiao_btn)
            assert '45' == dy, '断言失败(验证失败)'
            print(f'断言的内容:45 == {dy}')
            logging.info(f'断言的内容:45 == {dy}')
            logging.info(f'断言的内容:退出系统 == {dy}')

    def page_add_search(self, no):
        time.sleep(5)
        with allure.step(f"输入框输入搜索用户信息:{no}"):
            self.send_keys(home_pe.search_kuang, no)
        time.sleep(2)
        with allure.step("点击搜索按钮"):
            self.click(home_pe.search_btn)
        time.sleep(5)
        with allure.step("验证搜索出来的用户名"):
            dy = self.text(home_pe.tiao_btn)
            assert '1' == dy, '断言失败(验证失败)'
            print(f'断言的内容:1 == {dy}')
            logging.info(f'断言的内容:1 == {dy}')
            logging.info(f'断言的内容:退出系统 == {dy}')








